package com.example.administrator.caigou51.activity;

/**
 * Created by Administrator on 2016/9/22/022.
 */

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.caigou51.EventBusClass.GotoFragment;
import com.example.administrator.caigou51.EventBusClass.UpdateShopCarFragment;
import com.example.administrator.caigou51.EventBusClass.UpdateShopCarRedCount;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.bean.UserBean;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.global.AppManager;
import com.example.administrator.caigou51.recyclerCard.basic.MaterialListView;
import com.example.administrator.caigou51.recyclerCard.card.AddAgainGoodsCard;
import com.example.administrator.caigou51.util.ImageUtil;

import de.greenrobot.event.EventBus;


public class UserInfoActivity extends GBaseActivity {
    private LinearLayout linearLayoutUpdatePass;
    private TextView textViewLogOut;
    private ImageView imageViewHead;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        super.setContentViewFor720_1280(R.layout.activity_userinfo_manager);
        findViewByIds();
        initDatas();
        fillArrayInListView();
    }

    private void findViewByIds() {

        linearLayoutUpdatePass = (LinearLayout) findViewById(R.id.linearLayoutUpdatePass);linearLayoutUpdatePass.setOnClickListener(this);
        textViewLogOut = (TextView) findViewById(R.id.textViewLogOut);textViewLogOut.setOnClickListener(this);
        imageViewHead= (ImageView) findViewById(R.id.imageViewHead);
    }
    private void initDatas() {
        setTopTitle("账户管理");
        App.displayImageHttpOrFile(App.getUserBean().getAvatar(),imageViewHead, ImageUtil.OptionsNormalRadius360_Head());
    }
    private void fillArrayInListView() {
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId())
        {
            case R.id.textViewLogOut:
                App.userBean=null;
                App.saveUserBean(App.userBean);
                App.shopCarBeanList=null;
                App.orderList=null;
                App.collectBeanList=null;
                App.collectBeanListServer=null;
                App.saveCollectBeanListServer(App.collectBeanListServer);
                App.saveCollectBeanList(App.collectBeanList);
                App.saveOrderList(App.orderList);
                App.saveShopCarList(App.shopCarBeanList);

                Intent intent=new Intent(getActivity(),LoginActivity.class);
                startActivity(intent);
                AppManager.getAppManager().finishAllActivity();
               // finish();
               // EventBus.getDefault().post(new GotoFragment(MainActivity.TAB_ShouYe));
                //刷新购物车红点
                EventBus.getDefault().post(new UpdateShopCarRedCount());
                EventBus.getDefault().post(new UpdateShopCarFragment());
                break;
            case R.id.linearLayoutUpdatePass:
                Intent intent2=new Intent(getActivity(),FindPassActivity.class);
                startActivity(intent2);
                break;
        }
    }
}